package com.totcy.atom.view.activity;

import android.support.v7.widget.Toolbar;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.MenuItem;
import android.widget.EditText;

import com.totcy.atom.R;

import butterknife.BindView;

/**
 * 个人中心
 */
public class PersonalCenterActivity extends BaseFullActivity implements Toolbar.OnMenuItemClickListener, TextWatcher {
    @BindView(R.id.et_nickName)
    EditText etNickName;
    @BindView(R.id.et_age)
    EditText etAge;
    @BindView(R.id.et_address)
    EditText etAddress;

    private boolean isAddMenu = false;

    @Override
    public String getTitleName() {
        return getString(R.string.personal_center);
    }

    @Override
    public int getLayoutId() {
        return R.layout.activity_personal_center;
    }

    @Override
    public void initView() {

        etNickName.addTextChangedListener(this);
        etAge.addTextChangedListener(this);
        etAddress.addTextChangedListener(this);
    }

    @Override
    public boolean onMenuItemClick(MenuItem menuItem) {
        //保存


        return true;
    }

    @Override
    public void beforeTextChanged(CharSequence s, int start, int count, int after) {

    }

    @Override
    public void onTextChanged(CharSequence s, int start, int before, int count) {

    }

    @Override
    public void afterTextChanged(Editable s) {
        if (!isAddMenu) {
            getToolbarTitleLayout().inflateMenu(R.menu.menu_save);
            getToolbarTitleLayout().setOnMenuItemClickListener(this);
            isAddMenu = true;
        }
    }
}
